Skip to content

[YouTube] Switch to new search suggestion domain and improve error handling#1056

Merged
FireMasterK merged 3 commits intoTeamNewPipe:devfrom
AudricV:yt-improve-search-suggestions-extraction
May 2, 2023
Merged

[YouTube] Switch to new search suggestion domain and improve error handling#1056
FireMasterK merged 3 commits intoTeamNewPipe:devfrom
AudricV:yt-improve-search-suggestions-extraction

Conversation

@AudricV
Copy link
Copy Markdown
Member

@AudricV AudricV commented Apr 30, 2023

  • I carefully read the contribution guidelines and agree to them.

  • I have tested the API against NewPipe.

  • Switch to the new domain used by YouTube for search suggestions, suggestqueries-clients6.youtube.com, and add the xhr query parameter with the t value, to allow getting responses without requiring trim;

  • Use the Java 8 Stream API to collect search suggestions and improve invalid response detection by checking whether the content type of the response returned is JSON;

  • Improve YoutubeSuggestionExtractorTest and update its corresponding mocks.

AudricV added 3 commits April 30, 2023 19:53
…ndling

- Switch to the new domain used by YouTube for search suggestions,
suggestqueries-clients6.youtube.com, and add the xhr query parameter with the
t value, to allow getting responses without requiring trim;
- Use the Java 8 Stream API to collect search suggestions and improve invalid
response detection by checking whether the content type of the response
returned is JSON;
- Move the licence header at the top of the file.
- Remove useless concatenation on the downloader path;
- Remove unneeded public test modifier;
- Update license header;
- Specify the service class tested instead of the generic class.
@AudricV AudricV added enhancement New feature or request YouTube Service, https://www.youtube.com/ labels Apr 30, 2023
@FireMasterK
Copy link
Copy Markdown
Member

Would it make sense to fall back to the old search API if the new one fails? I've observed the new API being rate limited on Piped at times, so I think it could help.

@AudricV
Copy link
Copy Markdown
Member Author

AudricV commented May 1, 2023

Isn't the same rate limit applied when you switch the search suggestion host? It happens for YouTube manifests.

@FireMasterK
Copy link
Copy Markdown
Member

I've never really checked that, will see when I get rate limited again.

Copy link
Copy Markdown
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, @FireMasterK feel free to merge when you think it's ok :-)

@FireMasterK
Copy link
Copy Markdown
Member

FireMasterK commented May 2, 2023

It looks like the rate limits seem to be different, I tried the new search API on a rate-limited/blocked Piped node, and it worked when the old one failed.

@AudricV
Copy link
Copy Markdown
Member Author

AudricV commented May 2, 2023

Ok, so what should we do? Pick a search suggestion host randomly?

@FireMasterK
Copy link
Copy Markdown
Member

FireMasterK commented May 2, 2023

We could do that indeed. I was thinking we could use a static variable to store the last time we were rate limited as a long, and if been < 5 minutes, we use the old API. I can help with this if you'd like!

We get a 403 status code if we're rate limited.

@FireMasterK
Copy link
Copy Markdown
Member

It looks like I was using ipv6 on my testing, but my backends run on ipv4 only, the rate limit is also indeed on the new API, so I think this is ready to merge!

@FireMasterK FireMasterK merged commit a9ca5c4 into TeamNewPipe:dev May 2, 2023
@AudricV AudricV deleted the yt-improve-search-suggestions-extraction branch May 2, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request YouTube Service, https://www.youtube.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants